package smedi.ismedi.web.bff.controller.quality;

import com.smedi.ismedi.authority.starter.common.ResponseData;
import com.smedi.ismedi.instrument.api.dto.request.worksorder.*;
import com.smedi.ismedi.instrument.api.dto.response.worksorder.WorksOrderDetailResponse;
import com.smedi.ismedi.instrument.api.dto.response.worksorder.WorksOrderExportResponse;
import com.smedi.ismedi.instrument.api.dto.response.worksorder.WorksOrderResponse;
import com.smedi.ismedi.instrument.api.feign.RemoteWorksOrderFeignApi;
import com.smedi.ismedi.web.starter.common.PaginationData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @className: WorksOrderController
 * @Description: TODO
 * @version: v1.0.0
 * @author: wzx
 * @date: 2022/10/20 13:22
 */

@Slf4j
@RestController
@Api(tags = {"施工令接口"} , value = "施工令接口")
@RequestMapping("/webbff/v1/worksOrder")
@AllArgsConstructor
public class WorksOrderController {

    private final RemoteWorksOrderFeignApi worksOrderFeignApi;

    /**
     * 施工令(沉桩) 新增
     * @param worksOrderPileCreateRequest 沉桩新增
     * */
    @ApiOperation(value = "施工令(沉桩)新增",httpMethod = "POST")
    @PostMapping("/create/pile")
    ResponseData<WorksOrderResponse> createWorksOrder(@Validated @RequestBody WorksOrderPileCreateRequest worksOrderPileCreateRequest){
        return worksOrderFeignApi.createWorksOrder(worksOrderPileCreateRequest);
    }

    /**
     * 施工令(沉桩) 更新
     * @param worksOrderPileUpdateRequest 沉桩更新
     * */
    @ApiOperation(value = "施工令(沉桩)更新",httpMethod = "POST")
    @PostMapping("/update/pile")
    ResponseData<WorksOrderResponse> updateWorksOrder(@Validated @RequestBody WorksOrderPileUpdateRequest worksOrderPileUpdateRequest){
        return worksOrderFeignApi.updateWorksOrder(worksOrderPileUpdateRequest);
    }

    /**
     * 施工令(挖土) 新增
     * @param worksOrderWorkingCreateRequest 挖土新增
     * */
    @ApiOperation(value = "施工令(挖土)新增",httpMethod = "POST")
    @PostMapping("/create/working")
    ResponseData<WorksOrderResponse> createWorksOrder(@Validated @RequestBody WorksOrderWorkingCreateRequest worksOrderWorkingCreateRequest){
        return worksOrderFeignApi.createWorksOrder(worksOrderWorkingCreateRequest);
    }

    /**
     * 施工令(挖土) 更新
     * @param worksOrderWorkingUpdateRequest 挖土更新
     * */
    @ApiOperation(value = "施工令(挖土)更新",httpMethod = "POST")
    @PostMapping("/update/working")
    ResponseData<WorksOrderResponse> updateWorksOrder(@Validated @RequestBody WorksOrderWorkingUpdateRequest worksOrderWorkingUpdateRequest){
        return worksOrderFeignApi.updateWorksOrder(worksOrderWorkingUpdateRequest);
    }


    /**
     * 施工令(混凝土浇筑) 新增
     * @param worksOrderCreateRequest 混凝土新增
     * */
    @ApiOperation(value = "施工令(混凝土浇筑)新增",httpMethod = "POST")
    @PostMapping("/create/concreting")
    ResponseData<WorksOrderResponse> createWorksOrder(@Validated @RequestBody WorksOrderConcretingCreateRequest worksOrderCreateRequest){
        return worksOrderFeignApi.createWorksOrder(worksOrderCreateRequest);
    }

    /**
     * 施工令(混凝土浇筑) 更新
     * @param worksOrderUpdateRequest 混凝土更新
     * */
    @ApiOperation(value = "施工令(混凝土浇筑)更新",httpMethod = "POST")
    @PostMapping("/update/concreting")
    ResponseData<WorksOrderResponse> updateWorksOrder(@Validated @RequestBody WorksOrderConcretingUpdateRequest worksOrderUpdateRequest){
        return worksOrderFeignApi.updateWorksOrder(worksOrderUpdateRequest);
    }

    /**
     * 施工令(吊装) 新增
     * @param worksOrderCreateRequest 吊装新增
     * */
    @ApiOperation(value = "施工令(吊装)新增",httpMethod = "POST")
    @PostMapping("/create/hoisting")
    ResponseData<WorksOrderResponse> createWorksOrder(@Validated @RequestBody WorksOrderHoistingCreateRequest worksOrderCreateRequest){
        return worksOrderFeignApi.createWorksOrder(worksOrderCreateRequest);
    }

    /**
     * 施工令(吊装) 更新
     * @param worksOrderUpdateRequest 吊装更新
     * */
    @ApiOperation(value = "施工令(吊装)更新",httpMethod = "POST")
    @PostMapping("/update/hoisting")
    ResponseData<WorksOrderResponse> updateWorksOrder(@Validated @RequestBody WorksOrderHoistingUpdateRequest worksOrderUpdateRequest){
        return worksOrderFeignApi.updateWorksOrder(worksOrderUpdateRequest);
    }

    /**
     * 施工令(灌浆) 新增
     * @param worksOrderCreateRequest 灌浆新增
     * */
    @ApiOperation(value = "施工令(灌浆)新增",httpMethod = "POST")
    @PostMapping("/create/grout")
    ResponseData<WorksOrderResponse> createWorksOrder(@Validated @RequestBody WorksOrderGroutCreateRequest worksOrderCreateRequest){
        return worksOrderFeignApi.createWorksOrder(worksOrderCreateRequest);
    }

    /**
     * 施工令(灌浆) 更新
     * @param worksOrderUpdateRequest 灌浆更新
     * */
    @ApiOperation(value = "施工令(灌浆)更新",httpMethod = "POST")
    @PostMapping("/update/grout")
    ResponseData<WorksOrderResponse> updateWorksOrder(@Validated @RequestBody WorksOrderGroutUpdateRequest worksOrderUpdateRequest){
        return worksOrderFeignApi.updateWorksOrder(worksOrderUpdateRequest);
    }

    /**
     * 施工令列表
     * @param worksOrderPageRequest 分页请求
     * @return ResponseData<PaginationData<WorksOrderResponse>>
     * */
    @ApiOperation(httpMethod = "POST",value = "施工令列表")
    @PostMapping("/list/page")
    ResponseData<PaginationData<WorksOrderResponse>> listPage(@Validated @RequestBody WorksOrderPageRequest worksOrderPageRequest){
        return worksOrderFeignApi.listPage(worksOrderPageRequest);
    }

    /**
     * 施工令 查看
     * @param id  id
     * */
    @ApiOperation(httpMethod = "GET",value = "施工令查看")
    @GetMapping("/view/{id}")
    ResponseData<WorksOrderDetailResponse> view(@PathVariable Long id){
        return worksOrderFeignApi.view(id);
    }

    /**
     * 施工令 删除
     * @param id 施工令ID
     * */
    @ApiOperation(httpMethod = "DELETE",value = "施工令删除")
    @DeleteMapping("/delete/{id}")
    ResponseData<Boolean> deleteById(@PathVariable Long id){
        return worksOrderFeignApi.deleteById(id);
    }

    /**
     * 安全负责人审批
     * @param approveRequest 审批内容
     * */
    @ApiOperation(httpMethod = "POST" , value = "安全负责人施工令审批")
    @PostMapping("/approve/security")
    ResponseData<WorksOrderResponse> securityApproveWorksOrder(@Validated @RequestBody WorksOrderApproveRequest approveRequest){
        return worksOrderFeignApi.securityApproveWorksOrder(approveRequest);
    }

    /**
     * 质量负责人审批
     * @param approveRequest 审批内容
     * */
    @ApiOperation(httpMethod = "POST" , value = "质量负责人施工令审批")
    @PostMapping("/approve/quality")
    ResponseData<WorksOrderResponse> qualityApproveWorksOrder(@Validated @RequestBody WorksOrderApproveRequest approveRequest){
        return worksOrderFeignApi.qualityApproveWorksOrder(approveRequest);
    }

    /**
     * 机管负责人审批
     * @param approveRequest 审批内容
     * */
    @ApiOperation(httpMethod = "POST" , value = "机管负责人施工令审批")
    @PostMapping("/approve/engine")
    ResponseData<WorksOrderResponse> engineApproveWorksOrder(@Validated @RequestBody WorksOrderApproveRequest approveRequest){
        return worksOrderFeignApi.engineApproveWorksOrder(approveRequest);
    }

    /**
     * 施工项目总工审批
     * @param approveRequest 审批内容
     * */
    @ApiOperation(httpMethod = "POST" , value = "施工项目总工施工令审批")
    @PostMapping("/approve/chief")
    ResponseData<WorksOrderResponse> chiefApproveWorksOrder(@Validated @RequestBody WorksOrderApproveRequest approveRequest){
        return worksOrderFeignApi.chiefApproveWorksOrder(approveRequest);
    }

    /**
     * 施工项目经理审批
     * @param approveRequest 审批内容
     * */
    @ApiOperation(httpMethod = "POST" , value = "施工项目经理施工令审批")
    @PostMapping("/approve/manager")
    ResponseData<WorksOrderResponse> managerApproveWorksOrder(@Validated @RequestBody WorksOrderApproveRequest approveRequest){
        return worksOrderFeignApi.managerApproveWorksOrder(approveRequest);
    }

    /**
     * 主体院总管审批
     * @param approveRequest 审批内容
     * */
    @ApiOperation(httpMethod = "POST" , value = "主体院总管施工令审批")
    @PostMapping("/approve/org")
    ResponseData<WorksOrderResponse> orgApproveWorksOrder(@Validated @RequestBody WorksOrderApproveRequest approveRequest){
        return worksOrderFeignApi.orgApproveWorksOrder(approveRequest);
    }

    /**
     * 施工令审批撤回
     * @param approveCancelRequest 撤销请求
     * */
    @ApiOperation(httpMethod = "POST" , value = "审批撤回")
    @PostMapping("/approve/cancel")
    ResponseData<WorksOrderResponse> approveCancel(@Validated @RequestBody WorksOrderApproveCancelRequest approveCancelRequest){
        return worksOrderFeignApi.approveCancel(approveCancelRequest);
    }


    /**
     * 施工令导出
     * @param exportRequest 施工令IDs
     * */
    @ApiOperation(httpMethod = "POST",value = "施工令导出")
    @PostMapping("/export")
    ResponseData<List<WorksOrderExportResponse>> exportWorksOrder(@Validated @RequestBody WorksOrderExportRequest exportRequest){
        return worksOrderFeignApi.exportWorksOrder(exportRequest);
    }

}